package com.laolang.shop.modules.member.web.api;

import cn.hutool.core.util.StrUtil;
import com.laolang.shop.common.core.consts.ModuleNameConst;
import com.laolang.shop.common.core.domain.SimpleAjax;
import com.laolang.shop.common.core.util.LogUtil;
import com.laolang.shop.modules.auth.annotation.Auth;
import com.laolang.shop.modules.auth.util.SecurityUtil;
import com.laolang.shop.modules.member.logic.api.MemberAddressTagApiLogic;
import com.laolang.shop.modules.member.pojo.vo.MemberAddressTagVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author khlbat
 * @version 1.0
 * @date 2020/11/1 20:46
 */
@Slf4j
@RequestMapping("api/member/address/tag")
@RestController
public class MemberAddressTagApiController {


    @Autowired
    private MemberAddressTagApiLogic memberAddressTagApiLogic;

    @GetMapping("list")
    public SimpleAjax<List<MemberAddressTagVo>> list() {
        return SimpleAjax.ok(memberAddressTagApiLogic.list());
    }

    @GetMapping("query")
    public SimpleAjax<List<MemberAddressTagVo>> query() {
        return SimpleAjax.ok(memberAddressTagApiLogic.query());
    }

    @Auth
    @GetMapping("add")
    public SimpleAjax<Boolean> add() {
        LogUtil.info(log, ModuleNameConst.MEMBER,
                StrUtil.format("userId:{} tenantId:{} phone:{}",
                        SecurityUtil.getUserId(), SecurityUtil.getTenantId(), SecurityUtil.getTokenUser().getPhone()));
        return SimpleAjax.ok(memberAddressTagApiLogic.add());
    }
}
